
public class StringOps {
	//String is an immutable class
	
	
	
	
	
	public static void main(String[] args) {
		
		int i =2;
		int j=2; 
		
		Person  person1 = new Person();
		person1.age=2;
		person1.name="test";
		Person  person2 = new Person();
		person2.age=2;
		person2.name="test";
		
		if(person1 == person2)
		{
			System.out.println("equals");
		}
		
		if(person1.equals(person2))
		{
//			System.out.println("equals1");
		}
		
		
		
		
		
		String str = "abc";  //String str2 = new String("def"); .. created a string in pool
		String str1 = "abc";//whether this abc exist in pool
		
		
		//design pattern 
		//flyweight pattern
		
		if(str==str1)
		{
//			sSystem.out.println("string compare");
		}
		
		String str2 = new String("def");
		String str3 = new String("Def");
		
		if(str2==str3)
		{
			System.out.println("string compare for new");
		}
		
		if(str2.equalsIgnoreCase(str3))
		{
			System.out.println("string compare with equals without case issiues");
		}
		
		if(person1.equals(person2))
		{
			
		}
		
		String str4 = str2 + str3;
		System.out.println(str4);

		
		str4 = str2.concat(str3);
		System.out.println(str4);
		
		
		
		String a= 100 + "%" + str2;
		System.out.println("a= "+a);
		
		String b= 100 + '%' + str2;
		System.out.println("b= "+b);
		
		
		System.out.println("sum"+2+2);  // sum2 // sum22
		System.out.println("sum"+(2+2));//System.out.println("sum"+4) //
		

		
		String s9 = "mahender";
		
		
		if(s9.indexOf("hen") >= 0 )
		{
			System.out.println("yes");
		}
		
		System.out.println(s9.substring(5));
		
		String searchStr = "hen";
		System.out.println(s9.substring(s9.indexOf(searchStr)+searchStr.length() ));
		
		//Primitive Data value equality
		int i1=2, j1=3;
		
		
		if(j1 ==3 && i1==2){		//both condition evaluated and return true
			System.out.println("Hi 1");
		}
		
		if(j1 ==3 && i1==4){		////both condition evaluated and return false
			System.out.println("Hi 1");
		}
		
		
		
		if(i1 ==3 && j1==2){		//first condition evaluated and return false
			System.out.println("Hi 1");
		}
		
		if(i1 ==5 || j1==4){		//both condition evaluated and return false
			System.out.println("Hi 2");
		}
		
		if(i1 ==2 || j1==4){			//both condition evaluated and return true
			System.out.println("Hi 2");
		}
		

		if(i1 ==3 || j1==3){		//only 1 condition evaluated
			System.out.println("Hi 2");
		}
		
		
		
		if(i1 ==   j1)
		{
			
		}
		
		Person  person3 = new Person();
		person3.age=2;
		person3.name="test";
		Person  person4 = new Person();
		person4.age=2;
		person4.name="notest";
		
		
		Person person5 = person3;
		Person person6 = person3;
		Person person7 = person5;
		
		//Object Refrence Equality
		if(person3 == person5)
		{
			System.out.println("Same references");
		}
		
		//Object Data Value Equality
		if(person3.equals(person4))
		{
			System.out.println("Data value equality");
		}
		
		
		
		
	}
}
